<template>
  <div style="text-align:center;margin:auto;width:710px">
    <div id="programme"
         style="width:710px"
         ref="print">
      <xcgctTemplate></xcgctTemplate>
    </div>
    <div class="error500-btn-con">
      <el-button @click="myprint"
                 style="width: 200px;margin-top:10px"
                 type='primary'>打印</el-button>
    </div>
  </div>
</template>
<script>
import { getObj } from '@/api/cust/health/xcgct'
import xcgctTemplate from './xcgctTemplate'
export default {
  name: 'xcgct',
  components: {
    xcgctTemplate
  },
  data () {
    return {
      grjbxxid: '',
      jktjid: '',
      sfzh: '',
      data: []
    }
  },
  created () {
    this.grjbxxid = this.$route.query.grjbxxid
    this.jktjid = this.$route.query.id
    this.sfzh = this.$route.query.sfzh
    this.getObj()
  },
  mounted () { },
  methods: {
    getObj () {
      getObj({
        jktjid: this.jktjid,
        grjbxxid: this.grjbxxid,
        jktjsfzh: this.sfzh
      }).then(res => {
        this.data = res.data.data
      })
    },
    myprint () {
      this.$print(this.$refs.print)
    }
  },
  computed: {
    allData () {
      var newData = this.data
      if (this.data.length > 9) {
        var arr = this.data.slice(9, this.data.length)
        newData = this.data.slice(0, 9)
        for (var i = 0; i < arr.length; i++) {
          newData[i].jktjxmmc1 = arr[i].jktjxmmc
          newData[i].jktjjgsz1 = arr[i].jktjjgsz
          newData[i].jktjdw1 = arr[i].jktjdw
          newData[i].jktjckfw1 = arr[i].jktjckfw
        }
      }
      return newData
    }
  },
  props: []
}
</script>